from django.contrib import admin
from .models import ChatSession, ChatMessage, EmotionAnalysis, UserProfile


@admin.register(ChatSession)
class ChatSessionAdmin(admin.ModelAdmin):
    """AI对话会话管理"""
    list_display = ['id', 'user', 'session_id', 'start_time', 'is_active', 'created_at']
    list_filter = ['is_active', 'created_at']
    search_fields = ['user__username', 'session_id']
    date_hierarchy = 'created_at'
    ordering = ['-created_at']


@admin.register(ChatMessage)
class ChatMessageAdmin(admin.ModelAdmin):
    """AI对话消息管理"""
    list_display = ['id', 'session', 'role', 'emotion_type', 'emotion_intensity', 'timestamp']
    list_filter = ['role', 'emotion_type', 'timestamp']
    search_fields = ['content', 'session__session_id']
    date_hierarchy = 'timestamp'
    ordering = ['-timestamp']


@admin.register(EmotionAnalysis)
class EmotionAnalysisAdmin(admin.ModelAdmin):
    """情绪分析管理"""
    list_display = ['id', 'user', 'modality', 'confidence', 'analysis_time']
    list_filter = ['modality', 'analysis_time']
    search_fields = ['user__username']
    date_hierarchy = 'analysis_time'
    ordering = ['-analysis_time']


@admin.register(UserProfile)
class UserProfileAdmin(admin.ModelAdmin):
    """用户心理档案管理"""
    list_display = ['id', 'user', 'age', 'gender', 'occupation', 'privacy_level', 'updated_at']
    list_filter = ['gender', 'privacy_level']
    search_fields = ['user__username', 'occupation']
    ordering = ['-updated_at']
